package ycj.learn.springcloud.consumeruser.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import ycj.learn.springcloud.core.entities.Res;

@RestController
@RequestMapping("/consumer/consumeruser")
public class UserController {

    private static final String MICRO_SERVICE_NAME = "http://provider-consumeruser";


    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/{id}")
    public Res getOne(@PathVariable Long id) {

        return restTemplate.getForObject(MICRO_SERVICE_NAME+"/consumeruser/"+id, Res.class);
    }
}
